<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>pvread</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="pvoc.html" title="pvoc" />
    <link rel="next" href="pvsadsyn.html" title="pvsadsyn" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">pvread</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="pvoc.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="pvsadsyn.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="pvread"></a>
      <div class="titlepage"></div>
      <a id="IndexPvread" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">pvread</span>
        </h2>
        <p>pvread — 
      Reads from a phase vocoder analysis file and returns the frequency and amplitude from a single analysis channel or bin.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp137422592"></a>
        <h2>Description</h2>
        <p>
      <span class="emphasis"><em>pvread</em></span> reads from a <a class="link" href="pvoc.html" title="pvoc"><em class="citetitle">pvoc</em></a> file and returns the frequency and amplitude from a single analysis channel or bin. The returned values can be used anywhere else in the Csound instrument. For example, one can use them as arguments to an oscillator to synthesize a single component from an analyzed signal or a bank of <span class="emphasis"><em>pvreads</em></span> can be used to resynthesize the analyzed sound using additive synthesis by passing the frequency and magnitude values to a bank of oscillators.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp137425968"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">kfreq, kamp <span class="command"><strong>pvread</strong></span> ktimpnt, ifile, ibin</pre>
      </div>
      <div class="refsect1">
        <a id="idp137428176"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifile</em></span> -- the <span class="emphasis"><em>pvoc</em></span> number (n in pvoc.n) or the name in quotes of the analysis file made using <span class="emphasis"><em>pvanal</em></span>. (See <a class="link" href="pvoc.html" title="pvoc"><em class="citetitle">pvoc</em></a>.)
    </p>
        <p>
      <span class="emphasis"><em>ibin</em></span> -- the number of the analysis channel from which to return frequency in Hz and magnitude.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp137432640"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kfreq, kamp</em></span> -- outputs of the <span class="emphasis"><em>pvread</em></span> unit. These values, retrieved from a phase vocoder analysis file, represent the values of frequency and amplitude from a single analysis channel specified in the <span class="emphasis"><em>ibin</em></span> argument. Interpolation between analysis frames is performed at k-rate resolution and dependent of course upon the rate and direction of <span class="emphasis"><em>ktimpnt</em></span>. 
    </p>
        <p>
      <span class="emphasis"><em>ktimpnt</em></span> -- the passage of time, in seconds, through this file. <span class="emphasis"><em>ktimpnt</em></span> must always be positive, but can move forwards or backwards in time, be stationary or discontinuous, as a pointer into the analysis file.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp137437280"></a>
        <h2>Examples</h2>
        <p>
      The example below shows the use <span class="emphasis"><em>pvread</em></span> to synthesize a single component at a time from a phase vocoder analysis file. It should be noted that the <span class="emphasis"><em>kfreq</em></span> and <span class="emphasis"><em>kamp</em></span> outputs can be used for any kind of synthesis, filtering, processing, and so on.
      </p>
        <div class="example">
          <a id="idp137439776"></a>
          <p class="title">
            <strong>Example 668. Example of the pvread opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac  <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o pvread.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100 
<span class="ohdr">ksmps</span> <span class="op">=</span> 32 
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1 
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="oblock">instr</span> 1
<span class="comment">; analyze "fox.wav" with PVANAL first</span>
ibin  <span class="op">=</span> p4
ktime <span class="opc">line</span> 0, p3, 2.8
kfreq, kamp <span class="opc">pvread</span> ktime, "fox.pvx", ibin	<span class="comment">;read data from 7th analysis bin.</span>
asig  <span class="opc">poscil</span> kamp, kfreq, 1 			<span class="comment">;function 1 is a stored sine</span>
      <span class="opc">outs</span> asig<span class="op">*</span>5, asig<span class="op">*</span>5			<span class="comment">;compensate loss of volume</span>

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">;sine wave</span>
<span class="stamnt">f</span>1 0 4096 10 1

<span class="stamnt">i</span> 1 0 6 7
<span class="stamnt">i</span> 1 + 6 15
<span class="stamnt">i</span> 1 + 2 25
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
     </p>
      </div>
      <div class="refsect1">
        <a id="idp137444064"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="pvbufread.html" title="pvbufread"><em class="citetitle">pvbufread</em></a>, 
      <a class="link" href="pvcross.html" title="pvcross"><em class="citetitle">pvcross</em></a>, 
      <a class="link" href="pvinterp.html" title="pvinterp"><em class="citetitle">pvinterp</em></a>, 
      <a class="link" href="tableseg.html" title="tableseg"><em class="citetitle">tableseg</em></a>, 
      <a class="link" href="tablexseg.html" title="tablexseg"><em class="citetitle">tablexseg</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp137449952"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Richard Karpen</td>
          </tr>
          <tr>
            <td>Seattle, Wash</td>
          </tr>
          <tr>
            <td>1997</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 3.44</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="pvoc.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="pvsadsyn.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">pvoc </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> pvsadsyn</td>
        </tr>
      </table>
    </div>
  </body>
</html>
